//
//  MyDetailInfoViewController.m
//  OAProject
//
//  Created by yhj on 2017/2/22.
//  Copyright © 2017年 cdnunion. All rights reserved.
//  我的个人信息详情界面

#import "MyDetailInfoViewController.h"

static NSString *tableViewCellIdentifier=@"UITableViewCellIdentifier";
@interface MyDetailInfoViewController ()<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic,strong)UITableView *myDetailInfoTableView;

@property(nonatomic,strong)UIView *headView;

@property(nonatomic,strong)UIImageView *headURL;

@end


@implementation MyDetailInfoViewController

//-(instancetype)initWithUserModel:(UserModel *)userModel
//{
//    self=[super init];
//    if (self) {
//        self.userModel=userModel;
//    }
//    return self;
//}

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.title=@"个人信息";

    [self.view addSubview:self.myDetailInfoTableView];
    [self.headView addSubview:self.headURL];
}


// headURL
-(UIImageView *)headURL
{
    if (!_headURL) {
        _headURL=[[UIImageView alloc]initWithFrame:CGRectMake((APPW-kmargin*10)/2,kmargin*2,kmargin*10,kmargin*10)];
        _headURL.image=[UIImage imageNamed:@"head"];
        ViewBorderRadius(_headURL,kmargin*5,1,ClearColor);
    }
    return _headURL;
}


// headView
-(UIView *)headView
{
    if (!_headView) {
        _headView=[[UIView alloc]initWithFrame:CGRectMake(0,0,APPW,kmargin*14)];
        _headView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"myDetailInfo_bg"]];
    }
    return _headView;
}

// myDetailInfoTableView
-(UITableView *)myDetailInfoTableView
{
    if (!_myDetailInfoTableView) {
        _myDetailInfoTableView=[[UITableView alloc]initWithFrame:CGRectMake(0,0,APPW,APPH) style:UITableViewStylePlain];
        _myDetailInfoTableView.dataSource=self;
        _myDetailInfoTableView.delegate=self;
        _myDetailInfoTableView.backgroundColor=MAIN_BACK_COLOR;
      _myDetailInfoTableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
        self.myDetailInfoTableView.tableFooterView=[UIView new];
        self.myDetailInfoTableView.tableHeaderView=self.headView;
        [self.myDetailInfoTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:tableViewCellIdentifier];
    }
    return _myDetailInfoTableView;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSArray *arrTitle=@[@"姓名",@"手机",@"邮箱"];
//    NSArray *arrDetailTitle=@[@"研发部",self.userModel.mobile,self.userModel.email];
    NSArray *arrDetailTitle=@[@"研发部",@"13120568228",@"1787354782@qq.com"];
    UITableViewCell *cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:tableViewCellIdentifier];
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    cell.textLabel.text=arrTitle[indexPath.row];
    cell.detailTextLabel.text=arrDetailTitle[indexPath.row];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return kmargin*5;
}

// 间隙置边
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{

    if ([tableView respondsToSelector:@selector(setSeparatorInset:)])
    {
        [tableView setSeparatorInset:UIEdgeInsetsZero];
    }

    if ([tableView respondsToSelector:@selector(setLayoutMargins:)])
    {
        [tableView setLayoutMargins:UIEdgeInsetsZero];
    }

    if ([cell respondsToSelector:@selector(setLayoutMargins:)])
    {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

@end
